<template>
<!--pages/topicality/index/index.wxml-->
</template>

<script>
// pages/topicality/index/index.js
//获取应用实例
const app = getApp();
const util = require("../../../utils/util.js");
import fastnav from "../../../component/fastnav/fastnav";

export default {
  data() {
    return {
      topicId: "",
      citycode: "",
      city: ""
    };
  },

  components: {
    fastnav
  },
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var sceneData = [];

    if (options.scene != undefined) {
      var scene = decodeURIComponent(options.scene);
      var arrPara = scene.split("/");

      for (var i in arrPara) {
        sceneData.push(arrPara[i]);
      }
    }

    this.setData({
      topicId: sceneData[0] ? sceneData[0] : options.id ? options.id : '',
      citycode: sceneData[1] ? sceneData[1] : options.city ? options.city : uni.getStorageSync("citycode") ? uni.getStorageSync("citycode") : 'sz'
    });
    uni.setStorageSync('citycode', this.citycode);
    util.getUrl(app.globalData.url).then(res => {
      util.cityList().then(res => {
        let citydata = res.allcity.filter(v => v.citycode == this.citycode);
        this.setData({
          city: citydata[0].cityname
        });
        uni.setStorageSync('city', this.city);
      });
      this.getTopticlist();
    });
  },
  methods: {
    // 子专题列表
    getTopticlist() {
      let data = {
        action: "child",
        pid: this.topicId
      };
      util.request('zhuanti.php', data).then(res => {
        if (res.data.data) {
          let subList = res.data.data;
          if (subList && subList[0]) uni.redirectTo({
            url: '/pages/topicality/subtopic/subtopic?id=' + subList[0].id + '&city=' + this.citycode
          });
        } else {
          uni.switchTab({
            url: "/pages/index/index"
          });
        }
      });
    }

  }
};
</script>
<style>
/* pages/topicality/index/index.wxss */
.swimg{width: 100%;height: 319rpx;position: relative;}
.imgtext{background:rgba(0,0,0,0.41);padding:10rpx 20rpx;width:100%;
 font-size:28rpx;color: #ffffff;position: absolute;bottom: 0;}
.ztimg{width: 100%;height: 270rpx;}

.body{position: absolute;top:235rpx;background-color: #ffffff;
border-radius: 32rpx 32rpx 0 0;width: 100%;}
/* 我要办理 */
.center-icon{display:flex;align-items: center;justify-content: center;}
.banli-box1{border-bottom: 15rpx solid #EEEEEE;padding: 40rpx 35rpx;
border-radius: 32rpx 32rpx 0 0;}
.banli-box{border-bottom: 15rpx solid #EEEEEE;padding: 20rpx 35rpx;
border-radius: 32rpx 32rpx 0 0 ;}
.banli-box:last-child{border: 0;padding-bottom:0; }
.title{display: flex;flex-direction: row; align-items: center;flex: 1;}
.title image{width: 16rpx;height: 28rpx;margin-right: 10rpx;}
.title text{font-size:35rpx;font-family:PingFang SC;font-weight:600;color:rgba(53,53,53,1);
  line-height: 45rpx;}
  /* display: -webkit-flex;
  justify-content: space-between; */
.icon-box{display: flex;flex-direction: row;flex-wrap: wrap;margin-top: 30rpx;margin-left: 8rpx;}
.icon-style{display:flex;flex-direction: column;align-items: center;margin-right: 70rpx;
margin-top: 10rpx;}
.icon-style:nth-child(4n){margin-right: 0;}
.icon-style image{width:100rpx;height:100rpx;}
.icon-style text{font-size:28rpx;font-family:PingFang SC;font-weight:400;
  color:rgba(102,102,102,1);margin-top: 15rpx;margin-bottom: 20rpx;width: 112rpx;text-align: center;}

.newtext{font-size:30rpx;font-family:PingFang SC;font-weight:500;line-height:40rpx;
color:rgba(20,20,20,1);opacity:1;margin-top: 30rpx;}

/* 推荐文章 */
.flex-row{display: flex;align-items: center;justify-content: space-between;}
.more{display: flex;flex-direction: row; align-items: center;justify-content: center;}
.more text{font-size:28rpx;font-family:PingFang SC;font-weight:400;color:rgba(255,102,0,1);margin-right: 15rpx;}
.more image{width:14rpx;height:25rpx;}

.content{border-bottom: 1rpx solid #CCCCCC;padding:20rpx 0;display: flex;align-items: center;justify-content: space-between;
  margin-top: 10rpx;}
.content .title{display: flex;flex-direction: column;justify-content: space-between;align-items: flex-start;flex: 1;}
.content text{font-size:34rpx;font-family:PingFang SC;font-weight:400;color:rgba(0,0,0,1);}
.content image{width:188rpx;height:140rpx;border-radius:4rpx;margin-left: 20rpx;flex-shrink: 0;}
.zuan-time{display: flex;align-items: center;justify-content: space-between; margin-top:15rpx; 
  width: 100%;}
.zuanti{border:2rpx solid rgba(255,102,0,1);opacity:1;border-radius:16rpx;font-size:18rpx;
  font-family:PingFang SC;font-weight:500;color:rgba(255,102,0,1);padding:5rpx 12rpx;}
.time{font-size:24rpx;font-family:PingFang SC;font-weight:400;color:rgba(153,153,153,1);}

</style>